using System.ServiceProcess;
using Framework.Core.Process;

namespace Framework.Core.BootStrapper.WindowsService
{
    internal class WindowsServiceAdapter<TArgs> : ServiceBase
        where TArgs : IWindowsServiceArgs
    {
        private readonly IWindowsService<TArgs> windowsService;
        private readonly TArgs args;

        public WindowsServiceAdapter(IWindowsService<TArgs> windowsService, TArgs args)
        {
            this.windowsService = windowsService;
            this.args = args;
        }

        protected override void OnStart(string[] suppliedArgs)
        {
            windowsService.Start(args);
            base.OnStart(suppliedArgs);
        }

        protected override void OnStop()
        {
            windowsService.Stop();
            base.OnStop();
        }
    }
}